package net.wanho.controller;


import net.wanho.po.Permission;
import net.wanho.service.PermissionService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.wanho.vo.AjaxResult;
import net.wanho.vo.PermVo;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.List;

import lombok.RequiredArgsConstructor;



import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 权限表 前端控制器
 * </p>
 *
 * @author 汤小洋
 * @since 2025-09-25
 */
@Api(tags = "05.权限表接口")
@RestController
@RequestMapping("/rights")
@RequiredArgsConstructor
public class PermissionController {

    private final PermissionService permissionService;

    @ApiOperation("新增权限表")
    @PostMapping
    public AjaxResult add(@RequestBody Permission permission){
        permissionService.add(permission);
        return AjaxResult.success();
    }

    @ApiOperation("修改权限表")
    @PutMapping
    public AjaxResult modify(@RequestBody Permission permission){
        permissionService.modify(permission);
        return AjaxResult.success();
    }

    @ApiOperation("根据主键删除权限表")
    @DeleteMapping("/{psId}")
    public AjaxResult removeById(@PathVariable Serializable psId){
        permissionService.removeById(psId);
        return AjaxResult.success();
    }

    @ApiOperation("所有权限列表")
    @GetMapping("/{type}")
    public AjaxResult findByType(@PathVariable String type){
        List<PermVo>  list = permissionService.findByType(type);
        return AjaxResult.success(list);
    }

}
